(use-package eimp
  :hook
  (image-mode . eimp-mode)
  (image-mode . qrthi/display-line-numbers-mode-off)
  ;; (eimp-mode . qrthi/eimp-fit-image)
  ;; (eimp-mode . qrthi/set-kill-buffer-no-prompt)
  :bind
  (:map image-mode-map
	("H" . eimp-fit-image-height-to-window)
	("W" . eimp-fit-image-width-to-window)
	("M-b" . qrthi/image-backward-hscroll-far)
	("M-f" . qrthi/image-forward-hscroll-far)
	("q" . kill-current-buffer)
	([remap rename-buffer] . rename-file-and-buffer)
	)
  :custom
  (eimp-enable-undo t)
  :preface
  (defun qrthi/image-backward-hscroll-far ()
    (image-backward-hscroll 30))
  (defun qrthi/image-forward-hscroll-far ()
    (image-forward-hscroll 30))
  (defun qrthi/eimp-fit-image ()
    ;; I forgot what I was trying to do with this
    (if buffer-read-only
	(progn
	  (buffer-read-only nil)
	  (eimp-fit-image-to-window nil)
	  (buffer-read-only t))
      (eimp-fit-image-to-window nil)))
  ;; (defun qrthi/set-kill-buffer-no-prompt ()
  ;;   (progn
  ;;     (setq kill-buffer-query-functions
  ;;	    (delq 'process-kill-buffer-query-function kill-buffer-query-functions))))
  :init
  (defun rename-file-and-buffer (new-name)
    "Renames both current buffer and file it's visiting to NEW-NAME."
    (interactive "sNew name: ")
    (let ((name (buffer-name))
	  (filename (buffer-file-name)))
      (if (not filename)
	  (message "Buffer '%s' is not visiting a file!" name)
	(if (get-buffer new-name)
	    (message "A buffer named '%s' already exists!" new-name)
	  (progn
	    (rename-file filename new-name 1)
	    (rename-buffer new-name)
	    (set-visited-file-name new-name)
	    (set-buffer-modified-p nil)
	    (delete-file filename)
	    )))))

  )
